﻿ #region Disclaimer/Info
 
 /////////////////////////////////////////////////////////////////////////////////////////////////
 //
 //   File:		ArrayExtensions.cs
 //   Website:		http://dexterblogengine.com/
 //   Authors:		http://dexterblogengine.com/About.ashx
 //   Rev:		1
 //   Created:		19/01/2011
 //   Last edit:		19/01/2011
 //   License:		GNU Library General Public License (LGPL)
 //   File:            ArrayExtensions.cs
 //   For updated news and information please visit http://dexterblogengine.com/
 //   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
 //   For any question contact info@dexterblogengine.com
 //
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 #endregion
 
namespace System
{
	/// <summary>
	/// 	Adds behavior to array objects.
	/// </summary>
	public static class ArrayExtensions
	{
		/// <summary>
		/// 	Determines whether 2 arrays are structurally and content equals.
		/// </summary>
		/// <typeparam name = "T">The array item type.</typeparam>
		/// <param name = "array">The array.</param>
		/// <param name = "other">The other array.</param>
		/// <returns>
		/// 	<c>true</c> if the 2 arrays are equal; otherwise, <c>false</c>.
		/// </returns>
		public static Boolean IsEqualTo< T > ( this T[] array , T[] other )
		{
			if ( Equals ( array , other ) )
			{
				return true;
			}

			if ( array == null || other == null )
			{
				return false;
			}

			if ( array.Length != other.Length )
			{
				return false;
			}

			for ( int i = 0; i < array.Length; i++ )
			{
				T v1 = array [ i ];
				T v2 = other [ i ];

				if ( !Equals ( v1 , v2 ) )
				{
					return false;
				}
			}

			return true;
		}
	}
}
